from typing import Optional

from model.uml_element import UmlElement
from model.uml_comment import UmlComment
from model.uml_enumeration_literal import UmlEnumerationLiteral
from model.uml_xmi_info import UmlXmiInfo


class UmlEnumeration(UmlElement):
    def __init__(self) -> None:
        super().__init__(UmlXmiInfo.type_enumeration)
        self.name: str = ""
        self.ownedLiterals: list[UmlEnumerationLiteral] = []

    def to_json(self) -> dict[str, object]:
        json: dict = super().to_json()
        json["name"] = self.name

        if self.ownedComment is not None:
            json["ownedComment"] = self.ownedComment.to_json()

        item = []
        for value in self.ownedLiterals:
            item.append(value.to_json())
        json["ownedLiterals"] = item

        return json
